#include <stdio.h>
#include <time.h>
#include <unistd.h>
int main(int argc, const char *argv[])
{
	FILE *mylog=fopen("./mylog.txt","r+");
	int num=1;
	char mybuf[256];
	while(1)
	{
		time_t mytime=time(NULL);
		printf("%ld\n",mytime);

		char *buf=ctime(&mytime);
		puts(buf);
	
		struct tm *nowtime=localtime(&mytime);

		sprintf(mybuf,"year=%d month=%d day=%d  %d %d:%d:%d\n",nowtime->tm_year+1900,nowtime->tm_mon+1,nowtime->tm_mday,nowtime->tm_wday,nowtime->tm_hour,nowtime->tm_min,nowtime->tm_sec);
		fflush(mylog);
		fputs(mybuf,mylog);
		
		sleep(2);
	}
	return 0;
}
